﻿<%@ Page Title="" Language="C#" MasterPageFile="~/DeveloperSite.Master" AutoEventWireup="true" 
    CodeBehind="Users.aspx.cs" Inherits="Amkeni_System.CO.Users" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .tooltip
        {
            border:2px solid #317082;	/* Border width */
            left:18px;	/* Same as border thickness */
            top:0px;
            position:absolute;
            width:300px;	 /*Width of tooltip content */
            /*height:100px;	/* Height of tooltip content */
            background-color:#FFF;	/* Background color */
            padding:5px;	/* Space between border and content */
            font-size:1.0em;	/* Font size of content */
            overflow:auto;	/* Hide overflow content */
            z-index:1000001;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=Amkeni_DatabaseEntities" DefaultContainerName="Amkeni_DatabaseEntities" 
        EnableDelete="True" EnableUpdate="True" EnableFlattening="False" EntitySetName="users" 
        Include="implementing_partner">
    </asp:EntityDataSource>

    <%--<asp:EntityDataSource ID="RolesDataSource" runat="server" 
        ConnectionString="name=Amkeni_DatabaseEntities" DefaultContainerName="Amkeni_DatabaseEntities" 
        EnableFlattening="False" EntitySetName="roles" 
        Select="it.[role_id], it.[role1]">
    </asp:EntityDataSource>--%>

    <asp:EntityDataSource ID="RegionDataSource" runat="server"
        ConnectionString="name=Amkeni_DatabaseEntities" DefaultContainerName="Amkeni_DatabaseEntities"
        EnableFlattening="False" EntitySetName="regions">
    </asp:EntityDataSource>

    <asp:EntityDataSource ID="IPDataSource" runat="server" 
        ConnectionString="name=Amkeni_DatabaseEntities" DefaultContainerName="Amkeni_DatabaseEntities" 
        EnableFlattening="False" EntitySetName="implementing_partner" 
        Select="it.[ip_id], it.[abbreviation]">
    </asp:EntityDataSource>
    
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

    <div style="height:2em;">
        <div style="float:left;">
            <asp:Label ID="ContextLabel" runat="server" Text="USERS" CssClass="ContentHead"></asp:Label>
        </div>
        <% if (User.IsInRole("Administrator"))
           { %>
        <div style="float:right;">
            <asp:Button ID="AddUserButton" runat="server" Text="Add User" OnClick="AddUserButton_Click" />
        </div>
        <% }
           else
           { %>
            <div style="float:right;">
                <asp:Button ID="Button1" runat="server" Text="Add User" OnClick="AddUserButton_Click" Enabled="false" />
            </div>
        <% } %>
    </div>

    <% if (User.IsInRole("Administrator"))
       { %>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="user_id" 
                DataSourceID="EntityDataSource1" CssClass="NewGrid" ShowFooter="True">
                <AlternatingRowStyle CssClass="NewGridAlt" />
                <FooterStyle CssClass ="NewGridFooter" />
                <Columns>
                    <asp:BoundField DataField="user_id" HeaderText="user_id" ReadOnly="True" SortExpression="user_id" Visible="false" />
                    <asp:TemplateField HeaderText="First Name" SortExpression="first_name">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("first_name") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("first_name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Last Name" SortExpression="last_name">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("last_name") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("last_name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IP" SortExpression="ip_id">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ip_id") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("ip_id") %>'></asp:Label>
                            <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="Label1"
                                PopupControlID="Label7" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                            <asp:Label ID="Label7" runat="server" Text='<%# Eval("implementing_partner.abbreviation") %>' CssClass="tooltip"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Region" SortExpression="region">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("region") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label6" runat="server" Text='<%# Bind("region") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email" SortExpression="email">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("email") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("email") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="login_date" SortExpression="login_date" Visible="false">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("login_date") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("login_date") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CheckBoxField DataField="active" HeaderText="Active" SortExpression="active" />
                    <asp:CheckBoxField DataField="send_email" HeaderText="Send Notification" />
                    <asp:BoundField DataField="roles" HeaderText="Role(s)" SortExpression="roles" />
                    <asp:CommandField ShowEditButton="True" ButtonType="Button" HeaderText="EDIT" />
                    <asp:CommandField ShowDeleteButton="true" ButtonType="Button" HeaderText="Delete" />
                </Columns>
    </asp:GridView>
    <% }
       else
       { %>
            <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="user_id" 
                DataSourceID="EntityDataSource1" CssClass="NewGrid" ShowFooter="True">
                <AlternatingRowStyle CssClass="NewGridAlt" />
                <FooterStyle CssClass ="NewGridFooter" />
                <Columns>
                    <asp:BoundField DataField="user_id" HeaderText="user_id" ReadOnly="True" SortExpression="user_id" Visible="false" />
                    <asp:TemplateField HeaderText="First Name" SortExpression="first_name">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("first_name") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("first_name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Last Name" SortExpression="last_name">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("last_name") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("last_name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IP" SortExpression="ip_id">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ip_id") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("ip_id") %>'></asp:Label>
                            <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="Label1"
                                PopupControlID="Label7" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                            <asp:Label ID="Label7" runat="server" Text='<%# Eval("implementing_partner.abbreviation") %>' CssClass="tooltip"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Region" SortExpression="region">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("region") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label6" runat="server" Text='<%# Bind("region") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email" SortExpression="email">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("email") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("email") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="login_date" SortExpression="login_date" Visible="false">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("login_date") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("login_date") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CheckBoxField DataField="active" HeaderText="Active" SortExpression="active" />
                    <asp:CheckBoxField DataField="send_email" HeaderText="Send Notification" />
                    <asp:BoundField DataField="roles" HeaderText="Role(s)" SortExpression="roles" />
                </Columns>
    </asp:GridView>
    <% } %>

</asp:Content>
